package com.walter.service.impl;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.walter.dao.TeacherInfoDao;
import com.walter.dao.impl.TeacherInfoDaoImpl;
import com.walter.domain.TeacherInfo;
import com.walter.service.TeacherInfoService;
import com.walter.utils.HibernateUtils;

public class TeacherInfoServiceImpl implements TeacherInfoService {
	
	private TeacherInfoDao teacherInfoDao=new TeacherInfoDaoImpl();
	
	@Override
	public List<TeacherInfo> getAll() {
		Session session=HibernateUtils.getCurrentSession();
		//打开事务
		Transaction tx=session.beginTransaction();
		
		List<TeacherInfo> list=teacherInfoDao.getAll();
		
		//关闭事务
		tx.commit();
		return list;
	}

	@Override
	public long getCount() {
		
		return teacherInfoDao.getCount();
	}

	@Override
	public List<TeacherInfo> getAllByPage(int page) {

		return teacherInfoDao.getAllByPage(page);
	}

	@Override
	public List<TeacherInfo> getByName(String name) {
		return teacherInfoDao.getByName(name);
	}

	@Override
	public TeacherInfo getById(Long id) {
		return teacherInfoDao.getById(id);
	}


}
